<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>class Trello::Authorization::OAuthPolicy - RDoc Documentation</title>

<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
</script>

<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="../../index.html">Home</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>lib/trello/authorization.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="../../Object.html">Object</a>
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-authorize">::authorize</a>
    
    <li><a href="#method-c-new">::new</a>
    
    <li><a href="#method-i-authorize">#authorize</a>
    
    <li><a href="#method-i-consumer_key">#consumer_key</a>
    
    <li><a href="#method-i-consumer_secret">#consumer_secret</a>
    
    <li><a href="#method-i-oauth_token">#oauth_token</a>
    
    <li><a href="#method-i-oauth_token_secret">#oauth_token_secret</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="../../Gemfile.html">Gemfile</a>
  
    <li class="file"><a href="../../LICENSE.html">LICENSE</a>
  
    <li class="file"><a href="../../Rakefile.html">Rakefile</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="../../Trello.html">Trello</a>
  
    <li><a href="../../Trello/Action.html">Trello::Action</a>
  
    <li><a href="../../Trello/Association.html">Trello::Association</a>
  
    <li><a href="../../Trello/AssociationProxy.html">Trello::AssociationProxy</a>
  
    <li><a href="../../Trello/Attachment.html">Trello::Attachment</a>
  
    <li><a href="../../Trello/Authorization.html">Trello::Authorization</a>
  
    <li><a href="../../Trello/Authorization/BasicAuthPolicy.html">Trello::Authorization::BasicAuthPolicy</a>
  
    <li><a href="../../Trello/Authorization/Clock.html">Trello::Authorization::Clock</a>
  
    <li><a href="../../Trello/Authorization/Nonce.html">Trello::Authorization::Nonce</a>
  
    <li><a href="../../Trello/Authorization/OAuthPolicy.html">Trello::Authorization::OAuthPolicy</a>
  
    <li><a href="../../Trello/BasicData.html">Trello::BasicData</a>
  
    <li><a href="../../Trello/Board.html">Trello::Board</a>
  
    <li><a href="../../Trello/Card.html">Trello::Card</a>
  
    <li><a href="../../Trello/CheckItemState.html">Trello::CheckItemState</a>
  
    <li><a href="../../Trello/Checklist.html">Trello::Checklist</a>
  
    <li><a href="../../Trello/Client.html">Trello::Client</a>
  
    <li><a href="../../Trello/Configuration.html">Trello::Configuration</a>
  
    <li><a href="../../Trello/Error.html">Trello::Error</a>
  
    <li><a href="../../Trello/HasActions.html">Trello::HasActions</a>
  
    <li><a href="../../Trello/InvalidAccessToken.html">Trello::InvalidAccessToken</a>
  
    <li><a href="../../Trello/Item.html">Trello::Item</a>
  
    <li><a href="../../Trello/Label.html">Trello::Label</a>
  
    <li><a href="../../Trello/LabelName.html">Trello::LabelName</a>
  
    <li><a href="../../Trello/List.html">Trello::List</a>
  
    <li><a href="../../Trello/Member.html">Trello::Member</a>
  
    <li><a href="../../Trello/MultiAssociation.html">Trello::MultiAssociation</a>
  
    <li><a href="../../Trello/Notification.html">Trello::Notification</a>
  
    <li><a href="../../Trello/Organization.html">Trello::Organization</a>
  
    <li><a href="../../Trello/TInternet.html">Trello::TInternet</a>
  
    <li><a href="../../Trello/Token.html">Trello::Token</a>
  
    <li><a href="../../IntegrationTest.html">IntegrationTest</a>
  
    <li><a href="../../IntegrationTest/Container.html">IntegrationTest::Container</a>
  
    <li><a href="../../Helpers.html">Helpers</a>
  
    <li><a href="../../Object.html">Object</a>
  
    <li><a href="../../String.html">String</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class Trello::Authorization::OAuthPolicy</h1>

  <div id="description" class="description">
    
<p>Handles the OAuth connectivity to <a href="../../Trello.html">Trello</a>.</p>

<p>For 2-legged OAuth, do the following:</p>

<pre>OAuthPolicy.consumer_credential = OAuthCredential.new &quot;public_key&quot;, &quot;secret&quot;
OAuthPolicy.token               = OAuthCredential.new &quot;token_key&quot;, nil</pre>

<p>For 3-legged OAuth, do the following:</p>

<pre class="ruby"><span class="ruby-constant">OAuthPolicy</span>.<span class="ruby-identifier">consumer_credential</span> = <span class="ruby-constant">OAuthCredential</span>.<span class="ruby-identifier">new</span> <span class="ruby-string">&quot;public_key&quot;</span>, <span class="ruby-string">&quot;secret&quot;</span>
<span class="ruby-constant">OAuthPolicy</span>.<span class="ruby-identifier">return_url</span>          = <span class="ruby-string">&quot;http://your.site.com/path/to/receive/post&quot;</span>
<span class="ruby-constant">OAuthPolicy</span>.<span class="ruby-identifier">callback</span>            = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">request_token</span><span class="ruby-operator">|</span>
  <span class="ruby-constant">DB</span>.<span class="ruby-identifier">save</span>(<span class="ruby-identifier">request_token</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">request_token</span>.<span class="ruby-identifier">secret</span>)
  <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">request_token</span>.<span class="ruby-identifier">authorize_url</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Then, recreate the request token given the request token key and secret you
saved earlier, and the consumer, and pass that RequestToken instance the
get_access_token method, and store that in <a
href="OAuthPolicy.html#attribute-c-token">::token</a> as a OAuthCredential.</p>

  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <!-- Attributes -->
    <section id="attribute-method-details" class="method-section section">
      <h3 class="section-header">Attributes</h3>

      
      <div id="attribute-c-callback" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">callback</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-c-consumer_credential" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">consumer_credential</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-c-return_url" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">return_url</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-c-token" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">token</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-attributes" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">attributes</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-callback" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">callback</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-consumer_credential" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">consumer_credential</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-return_url" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">return_url</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-token" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">token</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
    </section><!-- attribute-method-details -->
    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-authorize" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">authorize</span><span
            class="method-args">(request)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="authorize-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">authorize</span>(<span class="ruby-identifier">request</span>)
  <span class="ruby-identifier">new</span>.<span class="ruby-identifier">authorize</span>(<span class="ruby-identifier">request</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- authorize-source -->
          
        </div>

        

        
      </div><!-- authorize-method -->

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(attrs = {})</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 80</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">attrs</span> = {})
  <span class="ruby-ivar">@consumer_key</span>       = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:consumer_key</span>]
  <span class="ruby-ivar">@consumer_secret</span>    = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:consumer_secret</span>]
  <span class="ruby-ivar">@oauth_token</span>        = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:oauth_token</span>]
  <span class="ruby-ivar">@oauth_token_secret</span> = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:oauth_token_secret</span>]
  <span class="ruby-ivar">@return_url</span>         = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:return_url</span>]          <span class="ruby-operator">||</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">return_url</span>
  <span class="ruby-ivar">@callback</span>           = <span class="ruby-identifier">attrs</span>[<span class="ruby-value">:callback</span>]            <span class="ruby-operator">||</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">callback</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-authorize" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">authorize</span><span
            class="method-args">(request)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="authorize-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">authorize</span>(<span class="ruby-identifier">request</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">consumer_credential</span>
    <span class="ruby-constant">Trello</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-string">&quot;The consumer_credential has not been supplied.&quot;</span>
    <span class="ruby-identifier">fail</span> <span class="ruby-string">&quot;The consumer_credential has not been supplied.&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">token</span>
    <span class="ruby-identifier">request</span>.<span class="ruby-identifier">headers</span> = {<span class="ruby-string">&quot;Authorization&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">get_auth_header</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">uri</span>, <span class="ruby-value">:get</span>)}
    <span class="ruby-identifier">request</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">consumer</span>(<span class="ruby-value">:return_url</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">return_url</span>, <span class="ruby-value">:callback_method</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:postMessage</span>)
    <span class="ruby-identifier">request_token</span> = <span class="ruby-identifier">consumer</span>.<span class="ruby-identifier">get_request_token</span>
    <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">request_token</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- authorize-source -->
          
        </div>

        

        
      </div><!-- authorize-method -->

    
      <div id="method-i-consumer_key" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">consumer_key</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="consumer_key-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 114</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">consumer_key</span>; <span class="ruby-identifier">consumer_credential</span>.<span class="ruby-identifier">key</span>; <span class="ruby-keyword">end</span></pre>
          </div><!-- consumer_key-source -->
          
        </div>

        

        
      </div><!-- consumer_key-method -->

    
      <div id="method-i-consumer_secret" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">consumer_secret</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="consumer_secret-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 115</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">consumer_secret</span>; <span class="ruby-identifier">consumer_credential</span>.<span class="ruby-identifier">secret</span>; <span class="ruby-keyword">end</span></pre>
          </div><!-- consumer_secret-source -->
          
        </div>

        

        
      </div><!-- consumer_secret-method -->

    
      <div id="method-i-oauth_token" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">oauth_token</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="oauth_token-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 116</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">oauth_token</span>; <span class="ruby-identifier">token</span>.<span class="ruby-identifier">key</span>; <span class="ruby-keyword">end</span></pre>
          </div><!-- oauth_token-source -->
          
        </div>

        

        
      </div><!-- oauth_token-method -->

    
      <div id="method-i-oauth_token_secret" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">oauth_token_secret</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="oauth_token_secret-source">
            <pre><span class="ruby-comment"># File lib/trello/authorization.rb, line 117</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">oauth_token_secret</span>; <span class="ruby-identifier">token</span>.<span class="ruby-identifier">secret</span>; <span class="ruby-keyword">end</span></pre>
          </div><!-- oauth_token_secret-source -->
          
        </div>

        

        
      </div><!-- oauth_token_secret-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

